import { CSSProperties, ReactNode } from "react";
import { ExpensesItemType, TypeFontFamily, TypeFontSize, TypeProjectSubTable, TableDataCell, XAxisType, YAxisType } from "../types";
import { ContentBlock, RawDraftInlineStyleRange } from "draft-js";
import { DocItem, DocItemType } from "../views/slate-editor";

interface UserType {
    key?: string;
    id?: string;
    account?: string;
    nickName?: string;
    avatar?: string;
    gender?: string;
    phone?: number;
    email?: string;
    groupId?: string;
    deptId?: string;
    roleId?: string;
    userType?: string;
    createUserName?: string;
    createUserId?: string;
    createDate?: string;
    updateDate?: string;
    updateUserName?: string;
    updateUserId?: string;
    expirationTime?: string;
    disable?: 0 | 1
}

interface DeptType {
    key?: string | number
    id?: string
    name?: string
    pid?: number
    createUserName?: string
    createUserId?: string
    createDate?: number
    updateDate?: string
    updateUserName?: string
    updateUserId?: string
    disable?: 0 | 1
    children?: Array<DeptType>
    sort?: number
    responsiblePerson?: string
    responsiblePersonTel?: string
    deletePopConfirmOpened?: boolean
};

interface SystemType {
    userInfo?: UserType
    deptInfo?: DeptType
    token?: string
}

interface TreeSelectType {
    value?: number
    title: string
    children: Array<TreeSelectType>
}

interface RoleType {
    key?: string | number
    id?: string
    name?: string
    pid?: number
    createUserName?: string
    createUserId?: string
    createDate?: number
    updateDate?: string
    updateUserName?: string
    updateUserId?: string
    disable?: 0 | 1
    children?: Array<DeptType>
    sort?: number
    menuList?: Array<any>
    systemList?: Array<any>
}

type TopicTag =
    'PlanningYears'                       //规划期限
    | 'EcologicalBenefitAnalysis'         //生态效益分析
    | 'SocialBenefitAnalysis'             //社会效益分析
    | 'SubSocialBenefitAnalysis'          //社会效益分析
    | 'EconomicBenefitAnalysis'           //经济效益分析
    | 'EnvironmentalCapacityAnalysis'     //环境容量分析
    | 'OverallGoal'                       //总体目标
    | 'ShortTermGoal'                     //近期目标
    | 'MediumAndLongTermGoals'            //中长期目标
    | 'MainProject'                       //重点工程
    | 'ExistingProblems'                  //存在问题与对策 大标题
    | 'MainContentsOfPlanning'            //规划主要建设内容 大标题
    | 'InvestmentPlan'                    //投资计划安排
    | 'PlanningInvestment'                //规划投资

type TopicCheckedStatus = 'fullChecked' | 'halfChecked' | 'noChecked';

interface TopicType {
    id?: string  //
    index?: number
    topicName?: string  //大纲名称（保护管理规划、保护区大门等等）
    sort?: string
    createDate?: number
    topicSortNumber?: string // 大纲编号 1、1.1 （一、二、）
    deviceSortNumber?: string // 设施设备编号 1、1.1 （一、二、）
    topicLevel?: '1' | '2' | '3' | '4' | '5' | '6' | string // 1~5
    backgroundParagraph1?: string  //longText 大纲背景文本
    backgroundParagraph2?: string  //longText 大纲背景文本
    backgroundParagraph3?: string  //longText 大纲背景文本
    backgroundParagraph4?: string  //longText 大纲背景文本
    topicType?: 'text' | 'device'  //标题文本、还是设施设备
    isUnionTopic?: boolean         //是否是联合的节点
    unionTextTopic?: TopicType
    unionDeviceTopic?: TopicType
    //设施设备属性
    unit?: string  //单位
    count?: string //数量
    unitPrice?: string //单价
    _unitPrice?: string //单价
    investmentCompositionType?: 'buildingInstallation' | 'device' | 'other'
    investmentCompositionMoney?: number,  //投资金额
    nearFutureMoneyRate?: number  //近期投资比例
    mediumAndLongTermMoneyRate?: number  //中长期投资比例
    nearFutureMoneyRateOfValue?: string  //近期投资比例
    mediumAndLongTermMoneyRateOfValue?: string  //中长期投资比例
    facilitiesBackgroundParagraph1?: string,  //设施背景文本1
    facilitiesBackgroundParagraph2?: string,  //设施背景文本2
    facilitiesBackgroundParagraph3?: string,  //设施背景文本3
    facilitiesBackgroundParagraph4?: string,  //设施背景文本4
    deviceBackgroundParagraph1?: string //设备背景文本1
    deviceBackgroundParagraph2?: string  //设备背景文本2
    deviceBackgroundParagraph3?: string //设备背景文本3
    deviceType?: 'S' | 'X',           //S代表设施，X代表设备
    mainProjectRecommand?: 0 | 1,      //是否推荐重点工程
    isMainProjectChcked?: boolean
    disable?: 0 | 1,
    areaConfigList?: Array<{
        min: string,
        max: string,
        unit: string
        recommandCount: string
    }>
    provinceConfigList?: Array<{
        provinceName: string
        customPrice: string
    }>
    adjustmentCoefficientByYear?: {
        type: 'decrement' | 'increment',  //递增还是递减
        coefficient: string
    }
    defaultRecommand?: 0 | 1,
    protectlandTypeIdList?: string[][]
    protectlandProblemList?: string[]
    pid?: string
    topicId?: string
    children?: TopicType[]
    title?: string
    key?: string
    treeLevel?: number,
    rowIndex?: number
    checked?: boolean
    isDeleted?: boolean
    remark?: string
    updateDate?: string
    isMainProject?: boolean
    isCustom?: boolean
    serialNumber?: string            //编号
    serialNumberByChecked?: string   //选中条件下的编号
    wordParagraphList?: WordParagraphBlock[],
    topicTag?: TopicTag
    currentInUseBackgroundParagraphIndex?: number
    childrenDeviceTopicListLength?: number //文本大纲下的设施设备数量
    subTopicList?: TopicType[]
    hasIncludeDeviceTopic?: boolean
    topicSlateDocItemList?: DocItem[]
    parentTextTopicTitle?: string
    directDeviceChildNodeCount?: number
    childDeviceNodeCount?: number
    childDeviceNodeCheckedCount?: number
    defaultChecked?: boolean
    // realCheckedStatus?: "fullChecke" | "halfChecked" | "noChecked"
    realCheckedStatus?: TopicCheckedStatus
    // topicSlateEditorInputInfoList?: []
}

interface TopicUnionRecord {
    textTopicId: string
    deviceTopicId: string
    textTopic: TopicType,
    deviceTopic: TopicType
}

interface ProtectlandType {
    id?: string
    type?: string   //保护地一级分类
    subType?: string  //保护地二级分类
    subTypeStr?: string
    topicSortNumber?: string  //大纲编号
    protectlandSortNumber?: string  //保护地分类编号
    groupId?: string
    sort?: string
    createDate?: string
    topicTemplateId?: string
    topicTemplateName?: string
    topicTemplateSortNumber?: string
    remark?: string
    children?: ProtectlandType[]
    label?: string
    value?: string
    _disabled?: boolean
}

interface TypeOptions {
    value: any
    label: string
    suffix?: '市' | '省' | '特别行政区' | '自治区'
    children?: TypeOptions[]
}

interface ProtectlandBaseInfoType {
    id?: string
    type?: string
    subType?: string
    protectlandLevel?: string
    protectlandProvince?: string
    protectlandName?: string
    protectlandArea?: string
    protectlandTypeId?: string
    protectlandAreaUnit?: string
    startYear?: any
    endYear?: any
    protectlandProblemList?: string
    yearRange?: any[]
    topicTemplateId?: string
    endYearStep?: string
    protectlandExtraInfo?: ProtectlandExtraInfoType
}

interface ProtectlandExtraInfoType {
    projectSubTableList: TypeProjectSubTable[]
    supplementaryInformation: SupplementaryInformationType
    protectedNaturalEnvironment: ProtectedNaturalEnvironmentType
}

interface SupplementaryInformationType {
    geographicalLocationText?: string
    rangeText?: string
    historicalEvolutionText?: string
    legalStatusText?: string
    mainProtectionObjecText?: string
    administrativeDivisionText?: string
    landOwnershipText?: string
    geologyAndGeomorphologyText?: string
    climateText?: string
    hydrologyText?: string
    soilText?: string
    vegetationText?: string
    fungusText?: string
    landscapeResourcesText?: string
    naturalDisasterText?: string
}

interface ProtectedNaturalEnvironmentType {
    geographicalLocationText?: string
    climateText?: string
}


interface TopicTemplateType {
    id?: string
    name?: string
    protectlandTypeId?: string
    sort?: string
    topicList?: TopicType[],
    remark?: string,
    sortNumber?: string
    createDate?: string
    updateDate?: string
}

interface SpeciesInfoType {
    type: 'mammal' | 'bird' | 'fungus' | 'plant' | 'insect' | 'amphibious'
    canorical_me: string,    //拉丁名 
    kingdom: string,         //界
    phylum: string,          //门
    class: string,           //纲
    order: string,           //目
    family: string,          //科
    genus: string,           //属
    kingdom_c: string,       //界(中文名)
    phylum_c: string,        //门(中文名)
    class_c: string,         //纲(中文名)
    order_c: string,         //目(中文名)
    family_c: string,        //科(中文名)
    genus_c: string,         //属(中文名)
    species_c: string,       //物种名称（学名）
    infraspecies_c: string,  //学名1
    infraspecies_c2: string, //学名2
    Commom_name: string      //俗名
    //以下是保护信息
    nationa_protection_level: string,  //国家级保护等级 默认空
    iucn_protection_level: string         //iucn保护等级 默认空
    cites_protection_level: string         //cites保护等级 默认空
};

interface BJHSpeciesInfoType {
    id?: string
    type: string
    researchType: string
    researchId?: string
    layerName?: string
    tableIndex?: string
    blockId?: string
    url?: string
    speciesName?: string
    species_name?: string
    rowId: string
    canorical_me: string
    kingdom: string
    phylum: string
    class: string
    order: string
    family: string
    kingdom_c: string
    phylum_c: string
    class_c: string
    order_c: string
    family_c: string
    genus: string
    genus_c: string
    species_c: string
    altitude?: string
    infraspecies_c: string
    infraspecies_c2: string
    Commom_name: string
    state_protection_grade: string
    endangered: 'all' | 'DD' | 'LC' | 'NT' | 'VU' | 'EN' | 'CR' | 'EW' | 'EX'
    CIETS: string
    latitude: string
    longitude: string
    remark: string
    voiceList: string
    imageList: string
    _imageList: any[]
    microHabitat: string
    serialNumberAndCode: string
    createDate: number,
    identificationStatus: string
    originSpeciesName: string
    is_delect: 0 | 1
    originType: string
    province_protection_grade: string
    province: string
    localId: string
    customAddress: string
}


interface DocInstance {
    id?: string
    docId?: string
    name?: string
    documentType?: string,
    hasSlaveDocument?: boolean,
    masterDocumentId?: string
    createUserName?: string
    protectlandTypeId?: string
    documentGroupId?: string
    protectedBaseInfoId?: string
    teamList?: UserType[],
    documentStatus?: string,
    sort?: string,
    remark?: string,
    isDeleted?: boolean,
    topicListId?: boolean
    createDate?: any
    updateDate?: any
    protectland?: ProtectlandType
    protectlandBaseInfo?: ProtectlandBaseInfoType
    protectlandProvince?: string
    topicList?: TopicType[],
    updateComponentName?: 'EditPageContainer' | 'EditPageNav' | 'TopicSliderBar' | 'ExcelEditor' | 'WordEditor' | 'TopicSettingPopover'
    dispatchFlow?: 'UP_TO_DOWN' | 'DOWN_TO_UP'
    sectionalizationId?: string
    status?: "1" | "2" | "3"
    topicTemplateId?: string
    protectlandExtraInfo?: ProtectlandExtraInfoType
    additionalDocItemList?: DocItem[]   //文档末尾追加的内容，比如附表的表格
}


interface CellStyleConfig {
    type?: 'cell' | 'col' | 'row'
    cellId?: string
    rowIndex?: number
    colIndex?: number
    inlineBackgroundColor?: string
    inlineFontSize?: TypeFontSize
    inlineFontFamily?: TypeFontFamily
    inlineFontColor?: string
    inlineFontItalic?: boolean
    inlineFontBold?: boolean
    inlineFontUnderLine?: boolean
    inlineFontDeleteLine?: boolean
    inlineFontSuperScript?: 'super' | 'sub'
    cellHorizontalAlign?: HorizontalAlignType
    cellVerticalAlign?: VerticalAlignType
    cellTextWrapMode?: '0' | '1' | '2'
}

type InlineStyleType =
    | 'inlineBackgroundColor'
    | 'inlineFontSize'
    | 'inlineFontFamily'
    | 'inlineFontColor'
    | 'inlineFontItalic'
    | 'inlineFontBold'
    | 'inlineFontUnderLine'
    | 'inlineFontDeleteLine'
    | 'inlineFontSuperScript'
    | 'cellVerticalAlign'
    | 'cellHorizontalAlign'
    | 'cellTextWrapMode'

type HorizontalAlignType = 'left' | 'center' | 'right';
type VerticalAlignType = 'top' | 'center' | 'bottom';

interface DocConfig {
    id?: string
    docId?: string
    updateComponentName?: 'EditPageContainer' | 'EditPageNav' | 'TopicSliderBar' | 'ExcelEditor' | 'WordEditor' | 'TopicSettingPopover'
    xAxisConfigList?: XAxisType[]
    yAxisConfigList?: YAxisType[]
    cellConfigList?: CellStyleConfig[]
    docBaseConfigInfo?: DocConfigBaseInfo
    docExtraConfigInfo?: DocExtraConfigInfo
    dispatchFlow?: 'UP_TO_DOWN' | 'DOWN_TO_UP',
    planBasisList?: PlanningBasisType[]
}

interface DocConfigBaseInfo {
    topicTreeLinkage?: boolean  //大纲联动
    showTopicTreeIcon?: boolean //大纲图标
    topicSideBarLocked?: boolean       //大纲锁定
    showTopicTreeLevel?: boolean   //展示当前大纲的序号
    systemRecommandNodeDeleted?: boolean
    docMoneyCardinalNumber?: number
    decimalNumber?: number //保留小数点位数
    otherExpensesItemList?: ExpensesItemType[]
    basicReserveExpensesList?: ExpensesItemType[]
}

interface CellBorderInfo {
    rangeType?: 'cell' | 'range',
    //如果是 cell
    value?: {
        row_index: number
        col_index: number
        l?: {
            style: CellBorderStyle,
            color: string
        }
        r?: {
            style: CellBorderStyle,
            color: string
        }
        t?: {
            style: CellBorderStyle,
            color: string
        }
        b?: {
            style: CellBorderStyle,
            color: string
        }
    }
    //如果是 range
    borderType?: RangeBorderType
    style?: CellBorderStyle
    color?: string
    range?: SheetGridRange[] | SheetGridRange //可以一次性设置多个选区
}

interface FrozenInfo {
    type: 'row' | 'column' | 'both' | 'rangeRow' | 'rangeColumn' | 'rangeBoth' | 'cancel'
    range: {
        row_focus: number,
        column_focus: number
    }
}

type OfficeUnit = 'inch' | 'cm' | 'mm' | 'lb'


type ExcelConfigType =
    'gridInfo'
    | 'borderInfo'
    | 'frozenInfo'
    | 'zoom'
    | 'mergeBoundInfo'
    | 'workSheetName';

type RangeBorderType =
    "border-left"  //左侧
    | "border-right"  //右侧
    | "border-top"    //上侧
    | "border-bottom" //下侧
    | "border-all"    //所有（选区里面框线）
    | "border-outside"  //外侧
    | "border-inside"   //内侧（暂时不需要）
    | "border-horizontal"  //内侧横线（暂时不需要）
    | "border-vertical"    //内侧竖线（暂时不需要）
    | "border-none"

type CellBorderStyle =
    0    // None
    | 1  //'Thin'      //细-实线
    | 2 //Hair        //细-线点-虚线
    | 3 //Dotted      //细-线点-虚线
    | 4 //Dashed      //细-线段-虚线
    | 5 //DashDot     //细-线点+线段虚线
    | 6 //DashDotDot  //细-双线点+线段虚线
    | 7 //Double      //2倍实线
    | 8 //Medium      //3倍实线
    | 9 //MediumDashed  //3倍线点-虚线
    | 10 //MediumDashDot //3倍线点+线段-虚线
    | 11 //MediumDashDotDot  //3倍双线点+线段虚线
    | 12 //SlantedDashDot   //暂时弃用
    | 13 //Thick      //粗匝


interface RowHeightConfig {
    rowIndex: number
    rowHeight: number
    rowHeightUnit: OfficeUnit
}

interface ColumnWidthConfig {
    columnIndex: number
    columnWidth: number
    columnWidthUnit: OfficeUnit
}

type RowHeightConfigMap = Record<number, RowHeightConfig>;
type ColumnWidthConfigMap = Record<number, ColumnWidthConfig>;

type ExcelColumnFillMode =
    'autoColumnWidth'
    | 'fillContainer'
    | 'fullScreen'

interface DocExtraConfigInfo {
    columnWidth?: number
    rowHeight?: number
    columnWidthUnit?: OfficeUnit
    rowHeightUnit?: OfficeUnit
    rowHeightConfigCollect?: RowHeightConfigMap
    columnWidthConfigCollect?: ColumnWidthConfigMap
    borderInfo?: CellBorderInfo[]  //边框信息
    frozenInfo?: FrozenInfo    //冻结窗格信息
    zoom?: number
    workSheetName?: string
    mergeBoundInfo?: any
    cutsomColumnWidthMap?: any
    cutsomRowHeightMap?: any
    dataVerificationMap?: any
    scrollInfo?: ExcelScrollInfo
    lastRowIndex?: number
    speciesInfoList?: SpeciesInfoType[]
    hasRecommandMainProject?: boolean
    excelColumnFillMode?: ExcelColumnFillMode
    hasOpenTopicManageModal?: boolean
}

interface DocOptionHistory {
    type: 'ChangeComDocInstance' | 'ChangecomDocConfig' | 'All'
    comDocInstance?: DocInstance
    comDocConfig?: DocConfig
}

interface SheetGridRange {
    row: number[]
    column: number[]
}

type TopicNodeActionType =
    'AddDeviceChildNode'
    | 'addChildTopic'
    | 'addPeerTopic'
    | 'AddTextChildNode'
    | 'AddDevicePeerNode'
    | 'AddTextPeerNode'
    | 'ReName'
    | 'MoveUp'
    | 'MoveDown'
    | 'MoveTop'
    | 'MoveBottom'
    | 'Delete'
    | 'UnChecked'

interface InlineContentSlice {
    content: string
    inlineStyleList: string[],
}

interface TopicDeviceParagraph {
    deviceGroupType?: 'S' | 'X',      //设施和设备
    deviceTopicList: TopicType[],
    currentFacilitiesBackgroundParagraph?: string,
    currentDeviceBackgroundParagraph?: string,
}


interface DeviceConstituteParagraphSliceInfo {
    deviceConstituteParagraphSlice: string[]
    currentTopic: TopicType
}

interface DeviceDescriptionSlice {
    deviceBackgroundParagraph: string
    deviceConstituteParagraphSliceList: DeviceConstituteParagraphSliceInfo[]
}



type EditorBlockParagraphType =
    'TextTopic'
    | 'TextTopicBackgroundParagraph'
    | 'TextTopicCustomBackgroundParagraph'
    | 'TextTopicDeviceDescriptionParagraph'

type DeviceAttributeType =
    '$[S]'
    | '$[X]'
    | '$[N]'
    | '$[U]'

interface EntityExtraData {
    textTopicId?: string   //文本大纲的id
    deviceTopicId?: string //设施设备大纲的id
    text?: string,
    deviceAttributeType?: DeviceAttributeType   //设施设备名称、数量、单位
}

interface DeviceEntityRange {
    key?: any
    text?: string
    textTopicId?: string
    deviceTopicId?: string
    deviceAttributeType?: DeviceAttributeType
    offset?: number
    textOffset?: number
    textLength?: number
    offsetWidth?: number
    start?: number
    end?: number
    entityKey?: string
    entityType?: string
    //8-28新增
    diffOffsetLength?: number
}

type CustomEntityType = 'SPECIAL_TEXT';

interface RawContent {
    blocks: any[],
    entityMap: any
}

interface ChangeBackgroundParagraphParams {
    topicWordParagraphList: WordParagraphBlock[]
    currentInUseBackgroundParagraphIndex: number
    focusParagraphBlock: ContentBlock
    textTopicId: string
}

type WordParagraphStyle =
    'title_paragraph_1'
    | 'title_paragraph_2'
    | 'title_paragraph_3'
    | 'title_paragraph_4'
    | 'title_paragraph_5'
    | 'title_paragraph_6'
    | 'normal_paragraph'
    | 'table_name_paragraph'
    | 'table_desc_paragraph'

type WordParagraphType =
    'topic_title'                     //标题等级
    | 'default_background_paragraph'  //系统默认背景文本
    | 'device_background_paragraph'   //系统设施设备文本段落（不可分段）
    | 'custom_background_paragraph'   //自定义背景文本（插件工具生成，插入）
    | 'table_name_paragraph'
    | 'table_desc_paragraph'

type WordParagraphSpecialMark =
    'high_light'

interface ColSpanInfo {
    rowIndex: number
    colIndex: number
    colSpan: number
}

interface RowSpanInfo {
    rowIndex: number
    colIndex: number
    rowSpan: number
}

interface WordParagraphBlockSlice {
    content: string
    styleList: string[]
}

interface WordParagraphBlock {
    textTopicId?: string
    blockId?: string
    type: 'text' | 'Table' | 'LaTex'
    isSubTable?: boolean  //是否是附表
    paragraphType?: WordParagraphType
    text?: string
    expressionLaTex?: string
    expressionOMML?: string
    paragraphStyle?: WordParagraphStyle
    inlineStyleRanges?: RawDraftInlineStyleRange[]
    specialMark?: WordParagraphSpecialMark[]
    entityRanges?: DeviceEntityRange[]
    tableData?: string[][]
    tableName?: string
    tableDesc?: string
    tableHeaderRowIndex?: number
    tableColSpanList?: ColSpanInfo[]
    tableRowSpanList?: RowSpanInfo[]
    sliceList?: WordParagraphBlockSlice[]
    docItem?: DocItem
}

interface EconomicPerformanceTableCell {
    key: string
    value: string
    type: string
    // target: '生态旅游收益' | '科学研究收益' | '文化教育收益' | '农业产品收益' | '生态养殖收益' | '种草药种植收益' | '风(水)能发电收益' | '森林木材保护价值' | '珍惜木材保护价值' | '野生木材保护价值'
    target: string
    actuality: string //现状值
    plan: string     //规划值
    benefit: string
}

interface FileItem {
    size: string
    createDate: number
    createUserId: string
    createUserName: string
    id: string
    pid?: string
    title?: string
    isDeleted: string
    isPublicShare: string
    name: string
    parentFolderId: string
    type: 1 | 2
    path: string
    url: string
    remark: string
    sort: string
    updateDate: string
    updateUserId: string
    updateUserName: string
}

interface DocGroupItem {
    id?: string,
    name?: string,
    createUserId?: null,
    updateUserName?: null,
    updateUserId?: null,
    sort?: 1,
    isDeleted?: false,
    remark?: null,
    createDate?: string,
    updateDate?: string,
    isDefault?: 1 | 0
}

interface SubTableConfig {
    tableData: string[][],
    tableHeaderRowIndex?: number
    tableColSpanList?: ColSpanInfo[]
    tableRowSpanList?: RowSpanInfo[]
}

type WordParagraphBlockStatus =
    'HighLight'
    | 'Modified'
    | 'SystemGeneration'
    | 'Reset'
    | 'Normal'

interface TopicTitleTagStatusConfig {
    PlanningYears: boolean
    EcologicalBenefitAnalysis: boolean
    SocialBenefitAnalysis: boolean
    SubSocialBenefitAnalysis: boolean
    EconomicBenefitAnalysis: boolean
    EnvironmentalCapacityAnalysis: boolean
    OverallGoal: boolean
    ShortTermGoal: boolean
    MediumAndLongTermGoals: boolean
    MainProject: boolean
    ExistingProblems: boolean
    MainContentsOfPlanning: boolean
    InvestmentPlan: boolean
    PlanningInvestment: boolean
}

type CellStyleNameType =
    'ff'        //fontfamily  字体   
    | 'fs'      //字体大小为 9px
    | 'fc'      //字体颜色
    | 'bl'      //字体加粗
    | 'ht'      //水平居中
    | 'vt'      //垂直居中
    | 'tb'      //文本自动换行
    | 'cl'      //cancelline 删除线
    | 'un'      //underline 删除线
    | 'tr'      //文字旋转 -45°
    | 'it'      //斜体
    | 'bg'

interface ExcelCellData {
    r?: number;
    c?: number
    // v?: any
    v?: {
        v: string | number,
        ff?: number | string;    //fontfamily  字体   
        fs?: number;             //字体大小为 9px
        fc?: string;             //字体颜色
        ht?: number;             //水平居中
        vt?: number;             //垂直居中
        tb?: string;             //文本自动换行
        cl?: number;             //启用删除线
        un?: number;             //
        tr?: string;             //文字旋转 -45°
        mc?: {                           //单元格合并属性
            r: number;
            c: number;
            rs?: number;
            cs?: number;
        };
    } | any
    m?: string | number;             //内容的显示值为 233

    f?: string;                      // "=SUM(233)" //单元格是一个求和公式
    ct?: {                           //单元格值格式
        fa?: string;                 //格式名称为自动格式
        t?: string;                  //"n"格式类型为数字类型
        s?: any;                     //
    };
    ps?: {   //批注框
        left: number | null;
        top: number | null;
        width: number | null;
        height: number | null;
        value: string;
        isShow: boolean;
    };
    bl?: number;             //字体加粗
    it?: number;             //字体斜体
    bg?: string;             //背景为 "#f6b26b"

    hl?: {
        r: number;
        c: number;
        id: string;
    };
    qp?: number;
    spl?: any;
    lo?: number;
    rt?: number;
}

type SheetConfig = {
    merge?: Record<string, {
        r: number;
        c: number;
        rs: number;
        cs: number;
    }>;
    rowlen?: Record<string, number>;
    columnlen?: Record<string, number>;
    rowhidden?: Record<string, number>;
    colhidden?: Record<string, number>;
    customHeight?: Record<string, number>;
    customWidth?: Record<string, number>;
    borderInfo?: any[];
    authority?: any;
    rowReadOnly?: Record<number, number>;
    colReadOnly?: Record<number, number>;
};

// interface ExcelCellData {
//     r?: number; //行
//     c?: number  //列
//     v?: {       //样式
//         v: string | number,
//         ff?: number | string;    //fontfamily  字体   
//         fs?: number;             //字体大小为 9px
//         fc?: string;             //字体颜色
//         ht?: number;             //水平居中
//         vt?: number;             //垂直居中
//         tb?: string;             //文本自动换行
//         un?: number;             //启用下划线
//     } 
//     m?: string | number;             //内容的显示值为 233
// }


type Image = {
    id: string;
    width: number;
    height: number;
    left: number;
    top: number;
    src: string;
};

interface LuckySheetSelectionRange {
    row: number[];
    column: number[];
    rowHeight?: number,
    columnWidth?: number
}

interface ExcelInstance {
    name: string;
    config?: SheetConfig;
    order?: number;
    color?: string;
    data?: ExcelCellData[][];
    celldata?: ExcelCellData[];
    id?: string;
    images?: Image[];
    zoomRatio?: number;
    column?: number;
    row?: number;
    addRows?: number;
    status?: number;
    hide?: number;
    luckysheet_select_save?: Selection[];
    luckysheet_selection_range?: LuckySheetSelectionRange[];
    calcChain?: any[];
    defaultRowHeight?: number;
    defaultColWidth?: number;
    showGridLines?: boolean | number;
    pivotTable?: any;
    isPivotTable?: boolean;
    filter?: Record<string, any>;
    filter_select?: {
        row: number[];
        column: number[];
    };
    luckysheet_conditionformat_save?: any[];
    luckysheet_alternateformat_save?: any[];
    dataVerification?: any;
    hyperlink?: Record<string, {
        linkType: string;
        linkAddress: string;
    }>;
    dynamicArray_compute?: any;
    dynamicArray?: any[];
    frozen?: {
        type: "row" | "column" | "both" | "rangeRow" | "rangeColumn" | "rangeBoth";
        range?: {
            row_focus: number;
            column_focus: number;
        };
    };
}


interface SheetSelection {
    row: number[];
    column: number[];
}

interface SelectOption {
    label?: string
    value?: string
    icon?: ReactNode
    tag?: string
    type?: string
    disable?: boolean
    province?: string
    area?: string
}


interface ExcelScrollInfo {
    scrollTop?: number
    scrollLeft?: number
    canvasHeight?: number
    targetRow?: number
    targetColumn?: number
}

interface SheetApiSettingParams {
    success?: () => void
    order?: number
    range?: SheetGridRange
}

interface DataVerificationItem {
    type: 'checkbox' | 'dropDown' | 'number' | 'number_integer' | 'number_decimal' | 'text_content' | 'text_length' | 'date' | 'validity',
    type2?: null,
    value1?: "是",
    value2?: "否",
    checked?: boolean,
    remote: boolean,
    prohibitInput?: boolean,
    hintShow?: boolean,
    hintText?: string
}


interface PlanningBasisType {
    id?: string
    basisName?: string
    basisType?: string
    protectlandType?: string[],
    protectlandSubType?: string
    province?: string
    isDeleted?: boolean
    topicTemplateSortNumber?: string
    sort?: string
    remark?: string
}

interface PlanningBasisGroupType {
    basisType?: string
    planningBasisList: PlanningBasisType[]
}

interface SearchSelectResult {
    value: string
    option: SelectOption
}

interface ExcelFormatBrush {
    enable: boolean
    type: 'single' | 'mutiple'
    tableDataCellList: TableDataCell[]
}

interface DocItemChangeRecord {
    changeType: 'added' | 'removed' | 'changed',
    docItemType: DocItemType
    docItemTextTopicId: string
    docItemId: string | number
    oldDocItem?: DocItem
    newDocItem?: DocItem
    textChanges?: any[],
    deletedMarkList?: string[],
}

//保护地名录
interface ProtectlandNameInfo {
    id: string
    protectlandName: string
    protectlandType: string
    protectlandSubType: string
    protectlandLevel: string
    province: string
    area: string
    sort: number,
    isDeleted: false,
    remark: null,
    createDate: string
    updateDate: string
    label?: string
}

type EditPageNavType = 'topic' | 'excel' | 'word';

export type {
    UserType,
    DeptType,
    SystemType,
    TreeSelectType,
    RoleType,
    TopicType,
    ProtectlandType,
    TypeOptions,
    TopicTemplateType,
    SpeciesInfoType,
    ProtectlandBaseInfoType,
    DocInstance,
    TopicNodeActionType,
    DocConfigBaseInfo,
    DocConfig,
    CellStyleConfig,
    DocOptionHistory,
    InlineStyleType,
    InlineContentSlice,
    TopicDeviceParagraph,
    DeviceDescriptionSlice,
    EntityExtraData,
    EditorBlockParagraphType,
    DeviceEntityRange,
    CustomEntityType,
    DeviceAttributeType,
    RawContent,
    ChangeBackgroundParagraphParams,
    WordParagraphBlock,
    WordParagraphType,
    EconomicPerformanceTableCell,
    ColSpanInfo,
    RowSpanInfo,
    FileItem,
    DocGroupItem,
    SubTableConfig,
    WordParagraphStyle,
    WordParagraphBlockStatus,
    TopicTitleTagStatusConfig,
    ExcelCellData,
    ExcelInstance,
    SheetSelection,
    CellStyleNameType,
    SelectOption,
    HorizontalAlignType,
    VerticalAlignType,
    DocExtraConfigInfo,
    OfficeUnit,
    FrozenInfo,
    ExcelConfigType,
    ExcelScrollInfo,
    SheetGridRange,
    SheetApiSettingParams,
    DataVerificationItem,
    CellBorderInfo,
    CellBorderStyle,
    RangeBorderType,
    WordParagraphBlockSlice,
    BJHSpeciesInfoType,
    PlanningBasisType,
    PlanningBasisGroupType,
    ProtectlandExtraInfoType,
    SupplementaryInformationType,
    ProtectedNaturalEnvironmentType,
    SearchSelectResult,
    LuckySheetSelectionRange,
    RowHeightConfigMap,
    ColumnWidthConfigMap,
    ExcelFormatBrush,
    DocItemChangeRecord,
    TopicUnionRecord,
    ProtectlandNameInfo,
    ExcelColumnFillMode,
    EditPageNavType,
    TopicCheckedStatus
}